﻿<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction
     Id="SPPropertyBagManagement.CustomActions.Items"
     Location="CommandUI.Ribbon"
     Rights="ManageWeb"
     Title="Property bag management"
     Sequence="100">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition
          Location="Ribbon.Documents.Manage.Controls._children">
          <Button Id="SPPropertyBagManagement.CustomActions.Items.Button"
            Command="AB6A58B5-2B68-4795-A3E9-4A6FA974B4BD"
            Sequence ="100"
            LabelText="Property bag management"
            Image16by16="/_layouts/images/SPPropertyBagManagement/propsIcon.gif"
            ToolTipTitle="Property bag management"
            ToolTipDescription="Manage item properties"
            TemplateAlias="o2" />
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler
          Command="AB6A58B5-2B68-4795-A3E9-4A6FA974B4BD"
          EnabledScript="javascript:(function (){return CountDictionary(SP.ListOperation.Selection.getSelectedItems()) == 1;})();"
          CommandAction="javascript: 
function navigateMe(){
var target = '{SiteUrl}/_layouts/SPPropertyBagManagement/PropertiesEdit.aspx?Scope=ListItem&amp;Id={SelectedListId}&amp;ItemId=';          
var context = SP.ClientContext.get_current(); 
var myItems = SP.ListOperation.Selection.getSelectedItems(context); 
var finalTarget;
finalTarget = String.format('{0}{1}', target, myItems[0].id);
window.location.href = finalTarget;
};
var res = navigateMe();
                        "
          />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
</Elements>